package com.ticker.national.twitter;

import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import twitter4j.auth.AccessToken;
import twitter4j.auth.Authorization;
import twitter4j.auth.AuthorizationFactory;
import twitter4j.auth.RequestToken;
import twitter4j.conf.ConfigurationBuilder;

public class MyTwitter {
	
	public final static String CONSUMER_KEY 	= "oMGAbxHu9ZI7hYZS69Png";
	public final static String CONSUMER_SECRET 	= "diDcDMfU9vfBZRGlB6RsD4PAdy6M65VQT8UMggqJB7s";
	
	private Twitter mTwitter;
	private static MyTwitter mTwitterInstance;
	private RequestToken mRequestToken;
	private AccessToken mAccessToken;
	
	private MyTwitter() {
		
		ConfigurationBuilder builder = new ConfigurationBuilder();
		builder.setOAuthConsumerKey(CONSUMER_KEY);
		builder.setOAuthConsumerSecret(CONSUMER_SECRET);
		builder.setHttpConnectionTimeout(10000); // default is 20,000
		builder.setHttpReadTimeout(60000); // default is 120,000
		
		Authorization auth = AuthorizationFactory.getInstance(builder.build());
		TwitterFactory factory = new TwitterFactory();
		
		mTwitter = factory.getInstance(auth);
	}
	
	public static MyTwitter getInstance() {
		if(mTwitterInstance == null)
			mTwitterInstance = new MyTwitter();
		
		return mTwitterInstance;
	}
	
	public Twitter getTwitter() {
		return mTwitter;
	}
	
	public void setRequestToken(RequestToken token) {
		mRequestToken = token;
	}
	
	public RequestToken getRequestToken() {
		return mRequestToken;
	}
	
	public void setAccessToken(AccessToken token) {
		mAccessToken = token;
	}
	
}
